﻿using System;
using System.Drawing;

namespace HighDiveEngine.Resources
{
    public class JudgeStatus : IEquatable<JudgeStatus>, IEquatable<JudgeStatus.Status>
    {
        public string Text { get; set; }
        public Color Color { get; set; }

        public JudgeStatus()
        {
            SetTo(Status.Na);
        }
        
        public bool Equals(JudgeStatus other)
        {
            return Text == other.Text && Color == other.Color;
        }

        public bool Equals(Status status)
        {
            switch (status)
            {
                case Status.Na: return Text == "N/A" && Color == Color.Black;
                case Status.Disconnected: return Text == "D/C" && Color == Color.Red;
                case Status.SlowReply: return Text == "Slow" && Color == Color.Orange;
                case Status.Connected: return Text == "OK" && Color == Color.Green;
            }
            return false;
        }

        public void SetTo(Status status)
        {
            switch (status)
            {
                case Status.Na:
                    Text = "N/A";
                    Color = Color.Black;
                    break;
                case Status.Disconnected:
                    Text = "D/C";
                    Color = Color.Red;
                    break;
                case Status.SlowReply:
                    Text = "Slow";
                    Color = Color.Orange;
                    break;
                case Status.Connected:
                    Text = "OK";
                    Color = Color.Green;
                    break;
            }
        }

        public enum Status
        {
            Na,
            Disconnected,
            SlowReply,
            Connected
        }
    }
}
